﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Trackr.GUI.Views
{
    /// <summary>
    ///     Interaction logic for TimeItem.xaml
    /// </summary>
    public partial class TimeItemView : UserControl
    {
        public TimeItemView()
        {
            InitializeComponent();
        }

        public TimeItemView(string task, TimeSpan duration)
            : this()
        {
            Task.Content = task;
            Task.ToolTip = task;
            Task.MouseDoubleClick += Task_MouseDoubleClick;
            Duration.Content = duration.ToString(@"%h\:mm");
        }

        private void Task_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var label = sender as Label;
            if (label != null)
                Clipboard.SetText(label.Content.ToString());
        }
    }
}